<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PrototypeDemo</title>
</head>
<body>
<ul>
    <li>
        1. instanceof是如何判断的?
        <ul>
            <li>表达式: A instanceof B</li>
            <li>如果B函数的显式原型对象在A对象的原型链上, 返回true, 否则返回false</li>
            <li>左边是看隐式，右边是显式</li>
            <li>Object实例是new Function()产生的</li>
        </ul>
    </li>
    <li>
        2. Function是通过new自己产生的实例
    </li>
</ul>


<script type="text/javascript">
    function Person() {
    }

    var person = new Person();
    var pointer01 = Person.prototype
    var pointer02 = person.__proto__
    console.log(person)//prototype=object
    console.log(typeof pointer01)//Object
    //l=Function--null r=null
    console.log(pointer01 instanceof Object)//Function
    console.log(typeof pointer02)//Function--Object--null
    console.log(pointer02)//Function--Object--null
    console.log(pointer01 === pointer02)

    console.log("=================Object===========")
    var obj = new Object()
    console.log(obj)//prototype=Object
    console.log(obj.__prototype__)//undefined
    console.log(Object.prototype)//Function--null

    console.log("=================Function===========")
    var func = new Function()
    console.log(func.__prototype__)//Function--null
    console.log(Function.prototype)//Function

    console.log("=================instanceof===========")
    //l:Function--Object--null r:Object
    console.log(person instanceof Person) // true
    //l:Function--Object--null r:Object
    console.log(person instanceof Object) // true
    //l:Function--null r:Function
    console.log(Object instanceof Function) // true
    //l:Function--null r:Function
    console.log(Object instanceof Object) // true
    //l:Function--null r:Function
    console.log(Function instanceof Function) // true
    //l:Function--null r:Function
    console.log(Function instanceof Object) // true
    function Person() {
    }

    //l:Function--null r:Object
    console.log(Object instanceof Person) // false
    //l:Function--null r:Object
    console.log(Function instanceof Person) // false
</script>
</body>
</html>